package cn.flying.cloud.file.view;

import javax.annotation.Resource;

import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.flying.cloud.file.bo.FileStorageBo;
import cn.flying.cloud.file.service.FileStorageService;
import cn.flying.cloud.system.common.service.CodeService;

/**
 * @author: admin
 * @date: 2025年09月04日 09:37
 * @version: 1.0
 */
@Controller
@RequestMapping("/file/storage")
public class FileStorageViewController {

    @Resource
    private CodeService codeService;
    @Resource
    private FileStorageService fileStorageService;

    /**
     * 列表页面
     *
     * @return
     */
    @RequestMapping("index")
    public String list(Model model) {
        Map<String, String> statusList = codeService.getCodeList("status");
        model.addAttribute("statusList", statusList);
        Map<String, String> smsVendors = codeService.getCodeList("sms_vendor");
        model.addAttribute("smsVendors", smsVendors);
        return "file/storage/index";
    }

    /**
     * 新增/修改页面
     *
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("turn/edit")
    public String turnEdit(Long id, Model model) {
        if (null != id) {
            model.addAttribute("formData", fileStorageService.getById(id));
        } else {
            FileStorageBo formData = new FileStorageBo();
//            info.setStatus("Y");
            model.addAttribute("formData", formData);
        }
        return "file/storage/edit";
    }
}
